package com.gizwits.akka

import  akka.actor._
import  akka.actor.Actor
import akka.actor.Actor.Receive
import akka.event.{LoggingAdapter, Logging}

import  akka.actor.ActorLogging

import scala.concurrent.duration.Duration

class  BecomeUncomeActor extends  Actor{


  val log:LoggingAdapter  = Logging.getLogger(context.system, this)
 override def receive: Receive ={
   case "go"=>{
     log.info("goo...")
       context.become{
         case "go" =>{
           log.info("become..")
            context.unbecome()
         }

       }


   }

  }
}

object BecomeUncome {
  def main(args: Array[String]) {

    val system = ActorSystem("HelloSystem")
    val p1 = system.actorOf(Props[BecomeUncomeActor], name = "p1")
    p1 ! "go"
    p1 ! "go"

    //kill actor
    //p1 ! Kill
    p1 ! "go"  //   messasg    sned deadLetters

      system.shutdown()
  }
}
